public class Solution3 {
    public static int lengthOfLongestSubstring(String s) {
        int result = 0, start = 0;
        int[] ch = new int[130];
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i);
            start = Math.max(start, ch[c]);
            result = Math.max(result, i + 1 - start);
            ch[c] = i + 1;
        }
        return result;
    }
}
